package design.singleton;

import java.util.concurrent.atomic.AtomicLong;

public class IdGenerator3 {
    private AtomicLong id = new AtomicLong(0);
    private IdGenerator3() {}
    private static class SingletonHolder{
        private static final IdGenerator3 instance = new IdGenerator3();
    }

    public static IdGenerator3 getInstance() {
        return SingletonHolder.instance;
    }

    public long getId() {
        return id.incrementAndGet();
    }
}
